//
//  GameOverScene.m
//  PlaneWar2
//
//  Created by HappyMilk 02 on 2017/4/6.
//  Copyright © 2017年 HappyMilk 02. All rights reserved.
//

#import "GameOverScene.h"
#import "GameScene.h"

@interface GameOverScene ()


@end

@implementation GameOverScene

- (void)didMoveToView:(SKView *)view{

    SKTexture *texture = [SKTexture textureWithImage:[UIImage imageNamed:@"paper_background"]];
    SKSpriteNode *background = [SKSpriteNode spriteNodeWithTexture:texture size:self.size];
    background.position = CGPointMake(self.size.width/2, self.size.height/2);
    background.zPosition = 0;
    [self addChild:background];
    //[self loadBackground];
    
    SKSpriteNode *alert = [SKSpriteNode spriteNodeWithImageNamed:@"paper_over"];
    alert.position = CGPointMake(self.size.width/2, self.size.height/2);
    [self addChild:alert];
    
    SKSpriteNode *menu = [SKSpriteNode spriteNodeWithImageNamed:@"btn_blue"];
    menu.position = CGPointMake(self.size.width/2, self.size.height/2+10);
    menu.name = @"menu";
    [self addChild:menu];
    
    SKSpriteNode *agin = [SKSpriteNode spriteNodeWithImageNamed:@"btn_green"];
    agin.position = CGPointMake(self.size.width/2, self.size.height/2-40);
    agin.name = @"agin";
    [self addChild:agin];
    
}

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    UITouch *touche = [touches.allObjects firstObject];
    CGPoint location = [touche locationInNode:self];
    
    SKNode *node = [self nodeAtPoint:location];
    if ([node.name  isEqual: @"menu"]) {
        NSLog(@"-----------");
        [[NSNotificationCenter defaultCenter] postNotificationName:@"dismiss" object:nil];
    }
    if ([node.name isEqual:@"agin"]) {
        [self.view presentScene:[GameScene sceneWithSize:self.size] transition:[SKTransition crossFadeWithDuration:0.5]];
    }
}



@end
